package com.wenx.concurrent.producerconsumer;

import java.util.Random;

/**
 * 客人 消费者
 * Created by wenx on 2019-10-18 15:21
 */
public class EaterThread extends Thread {

    private final Random random;
    private final Table table;
    public EaterThread(String name, Table table, long seed) {
        super(name);
        this.table = table;
        this.random = new Random(seed);
    }
    public void run() {
        try {
            while (true) {
                String cake = table.take();
                Thread.sleep(random.nextInt(1000));
            }
        } catch (InterruptedException e) {
        }
    }

}